home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / buildSetCharacterMenu.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.2 KB  |  140 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //    Alias|Wavefront Script File
  19. //    MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //    Creation Date:  23 November 1998
  22. //    Author:         mt
  23. //
  24. //  Procedure Name:
  25. //      buildSetCharacterMenu
  26. //
  27. //  Description:
  28. //      build the menu used for quickly selecting the current character
  29. //
  30. //  Input Arguments:
  31. //      Name of the parent menu
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36. proc int
  37. createCharacterMenuItem(string $character,
  38.                         string $currentCharacter,
  39.                         int $submenu)
  40. {
  41.     int $characterRadioOn = false;
  42.     $radioState = ( $character == $currentCharacter );
  43.     if ( $radioState ) {
  44.         $characterRadioOn = true;
  45.     }
  46.     $cmd = ( "setCurrentCharacters( { \"" + $character + "\" } )" );
  47.     $annotation = ( "Set current character to " + $character );
  48.     
  49.     string $chmem[] = `character -q $character`;
  50.     string $subcharacters[] = `ls -type character $chmem`;
  51.     int $submenu = (size($subcharacters) > 0);
  52.     menuItem -l $character -c $cmd -annotation $annotation  -sm $submenu
  53.         -radioButton $radioState;        
  54.     if ($submenu) {
  55.         menuItem -l $character -c $cmd -annotation $annotation
  56.             -radioButton $radioState;
  57.         menuItem -d true;        
  58.         for ($sub in $subcharacters) {
  59.             if (createCharacterMenuItem($sub,
  60.                                         $currentCharacter,1)) {
  61.                 $characterRadioOn = true;
  62.             }
  63.         }
  64.         setParent -m ..;
  65.     }
  66.     return $characterRadioOn;
  67. }
  68.  
  69. global proc buildSetCharacterMenu( string $menu ) 
  70. {
  71.     menu -edit -dai $menu;
  72.     setParent -m $menu;
  73.     int $characterRadioOn = false;
  74.  
  75.     // Get the list of top-level characters from the character partition
  76.     //
  77.     string $characters[] = `partition -query characterPartition`;
  78.     string $currentCharacters[] = currentCharacters();
  79.  
  80.     // Determine if there is a single current character
  81.     //
  82.     string $currentCharacter = "";
  83.     if ( size( $currentCharacters ) == 1 ) {
  84.         $currentCharacter = $currentCharacters[0];
  85.     }
  86.  
  87.     // Put in the "None" menu item
  88.     //
  89.     radioMenuItemCollection;
  90.     int $radioState; 
  91.     $radioState = ( size( $currentCharacters ) == 0 );
  92.     $cmd = "setCurrentCharacters( {} )";
  93.     menuItem -l "None" -command "ClearCurrentCharacterList" 
  94.         -annotation "None: Clear current character list"
  95.         -radioButton $radioState;
  96.  
  97.     // Put in another divider, but only if there are characters
  98.     // to list in the top-level character section of the menu
  99.     //
  100.     if ( size( $characters ) > 0 ) {
  101.         menuItem -d true;
  102.     }
  103.  
  104.     // Put in the radio buttons for all of the top-level characters
  105.     // in the scene
  106.     //
  107.     string $cmd, $annotation;
  108.     for ( $character in $characters ) {
  109.         if (createCharacterMenuItem($character,
  110.                                     $currentCharacter, 0)) {
  111.             $characterRadioOn = true;
  112.         }
  113.     }
  114.  
  115.     menuItem -d true;
  116.  
  117.     // Put in the special case item for multiple or sub characters selected
  118.     //
  119.     int $radioState = ( ( size( $currentCharacters ) > 0 ) && !$characterRadioOn );
  120.     string $label, $annotation;
  121.     if ( $radioState ) {
  122.         if ( size( $currentCharacters ) > 1 ) {
  123.             // There are multiple characters selected
  124.             //
  125.             $label = "Multiple";
  126.             $annotation = "Multiple current characters set from the character editor";
  127.         } else {
  128.             // There is only one character selected, so it must be
  129.             // a sub character
  130.             //
  131.             $label = "Sub Character";
  132.             $annotation = "Sub character set from the character editor";
  133.         }
  134.         menuItem -l $label -radioButton true -annotation $annotation;
  135.     }
  136.     menuItem -l "Character Sets..." -c "characterEditor( true )"
  137.         -annotation "Character Sets: Open character editor";
  138.  
  139. }
  140.